package Atop100.listNode;


import listNodePractice.ListNode;

import java.util.PriorityQueue;

public class Class148  {


    public ListNode sortList(ListNode head) {
//TODO:2023/10/27  不对的声明
//        PriorityQueue<ListNode> priorityQueue = new PriorityQueue<ListNode>((a,b)->{a.val-b.val});

//        PriorityQueue<>   B=new PriorityQueue<>((x,y) -> (y-x));
        PriorityQueue<ListNode> pq = new PriorityQueue<>((a, b)->(a.val - b.val));
        ListNode p=head;
        while (p!=null){
            pq.offer(p);
            p=p.next;
        }
        ListNode dumpy = new ListNode(-1);
        ListNode q=dumpy;
        while (!pq.isEmpty()){
           q.next= pq.poll();
           q=q.next;
        }
        q.next=null;
        return  dumpy.next;



    }


    public static void main(String[] args) {




    }


}
